import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/layout.vue'

const routes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // 相对写法：不以/号开头，就相对于父级  父级path+/+自己的path，绝对写法:以/号开头
        component: () => import('@/views/home/index.vue')
      },

      {
        // 1级菜单
        path: 'category/:id',
        component: () => import('@/views/category/index.vue')
      },
      {
        // 2级菜单
        path: 'category/sub/:id',
        component: () => import('@/views/category/sub.vue')
      },
      {
        // 产品详情
        path: 'product/:id',
        component: () => import('@/views/product/index.vue')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
